//
//  EHSingleChooseViewController.m
//  EasyHomePM
//
//  Created by MingleChang on 16/8/27.
//  Copyright © 2016年 wzkj. All rights reserved.
//

#import "EHSingleChooseViewController.h"

static NSString* kSingleChooseCellID=@"kSingleChooseCellID";

@interface EHSingleChooseViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation EHSingleChooseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self configure];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark - Configure
-(void)configure{
    [self configureView];
    [self configureData];
}
-(void)configureView{
    self.view.backgroundColor=[UIColor whiteColor];
    self.tableView.backgroundColor=[UIColor whiteColor];
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:kSingleChooseCellID];
}
-(void)configureData{
    
}

#pragma mark - Delegate
#pragma mark - TableView DataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.options.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSInteger row=[indexPath row];
    UITableViewCell *lCell=[tableView dequeueReusableCellWithIdentifier:kSingleChooseCellID forIndexPath:indexPath];
    lCell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    lCell.textLabel.textColor=[UIColor tm_LabelTextColor];
    NSString *lString=[self.options objectAtIndex:row];
    lCell.textLabel.text=lString;
    lCell.textLabel.font=[UIFont systemFontOfSize:14];
    

    UIView *lineView=[lCell.contentView viewWithTag:9090];
    if (!lineView) {
        lineView=[[UIView alloc]initWithFrame:CGRectMake(15, 45-1, kScreenWidth-15, 1)];
        lineView.backgroundColor=[UIColor tm_backgroundColor];
        lineView.tag=9090;
        [lCell.contentView addSubview:lineView];
    }
    lineView.hidden=(row==self.options.count-1);
    
    return lCell;
}
#pragma mark - TableView Delegate
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 15;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSInteger row=[indexPath row];
    if (self.selectedIndexBlock) {
        self.selectedIndexBlock(row);
    }else{
        [self.navigationController popViewControllerAnimated:YES];
    }
}

#pragma mark - super
- (void)resetNavigationBarItems {
    [super resetNavigationBarItems];
    self.title = @"选择房源";
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
